package cn.okcmd.juc;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicIntegerArray;

/**
 * create by caoqg on 2021/7/17
 * 功能说明:
 **/
@Slf4j
public class TestAtomicIntegerArray {
    public static void main(String[] args) {
        int[] arr=new int[]{1,2,3,4};
        log.info("old arr:{}",arr);
        AtomicIntegerArray aia = new AtomicIntegerArray(arr);
        for (int i = 0; i < arr.length; i++) {
            aia.incrementAndGet(i);
        }
        for (int i = 0; i < aia.length(); i++) {
            int val = aia.get(i);
            log.info("index:{},val:{}",i,val);
        }

    }
}
